/**
 * @author LKQ
 * @date 2022/2/14 20:41
 * @description 模拟，每一次除2，然后比较余数
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.hasAlternatingBits(11);
    }

    public boolean hasAlternatingBits(int n) {
        while (n != 0) {
            int now = n % 2;
            n /= 2;
            if (now == n % 2) {
                return false;
            }
        }
        return true;
    }
}
